package com.infura;

import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;

import java.io.IOException;

public class Web3ConnectionExample {
    public static void main(String[] args) {
        // 替换为你自己的 Infura 项目 ID
        String infuraUrl = "https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID";
        Web3j web3 = Web3j.build(new HttpService(infuraUrl));

        try {
            // 测试连接，获取以太坊客户端版本
            String clientVersion = web3.web3ClientVersion().send().getWeb3ClientVersion();
            System.out.println("以太坊客户端版本: " + clientVersion);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}